harden ember-server — auth rate limiting, pubsub limits, integer safety - #102
Merged
Conversation
- add MAX_AUTH_FAILURES (10) constant in connection_common.rs - track failed AUTH attempts per connection, disconnect after 10 failures - apply to both sharded (connection.rs) and concurrent handler - cap slowlog integer fields with .min(i64::MAX) before as-cast to prevent truncation on very large IDs or timestamps
- add MAX_SUBSCRIPTIONS_PER_CONN (10,000) to prevent memory exhaustion from a single client creating unbounded broadcast channels - add MAX_PATTERN_LEN (256) to prevent pathological glob backtracking from very long PSUBSCRIBE patterns - enforce both limits in handle_sub_command with clear error messages
use try_from with saturating fallback instead of bare `as u32` cast on max_conn, preventing truncation if a very large value is configured.
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
…ty (#102) * harden: auth brute-force protection and slowlog integer safety - add MAX_AUTH_FAILURES (10) constant in connection_common.rs - track failed AUTH attempts per connection, disconnect after 10 failures - apply to both sharded (connection.rs) and concurrent handler - cap slowlog integer fields with .min(i64::MAX) before as-cast to prevent truncation on very large IDs or timestamps * harden: pub/sub subscription limits and pattern length cap - add MAX_SUBSCRIPTIONS_PER_CONN (10,000) to prevent memory exhaustion from a single client creating unbounded broadcast channels - add MAX_PATTERN_LEN (256) to prevent pathological glob backtracking from very long PSUBSCRIBE patterns - enforce both limits in handle_sub_command with clear error messages * harden: safe u32 conversion in drain_connections use try_from with saturating fallback instead of bare `as u32` cast on max_conn, preventing truncation if a very large value is configured. * fmt: rustfmt import ordering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
hardens the server crate against several attack vectors and integer safety issues identified during security audit:
as_micros(), entry IDs, and timestamps with.min(i64::MAX)before casting to prevent silent truncation on very large values.try_fromwith saturating fallback instead of bareas u32cast on max_conn.what was tested
cargo clippy -p ember-servercleancargo check -p ember-servercleanas i64/as u32/as usizecasts in the cratedesign considerations